﻿using cpe.cpein.SERVER.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace cpe.cpein.SERVER.Tools
{
    public static partial class ObjectConverter
    {
        /// <summary>
        /// Function used to convert a WS Skill to a Data Skill.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static DATA.Skill SkillConverter(Skill Skill)
        {
            if (Skill == null)
                return null;

            return new DATA.Skill()
            {
                skl_id = Skill.Id,
                skl_isdeleted = Skill.IsDeleted,
                skl_label = Skill.Label
            };
        }

        /// <summary>
        /// Function used to convert a Data Skill to a WS Skill.
        /// </summary>
        /// <param name="?"></param>
        /// <returns></returns>
        public static Skill SkillConverter(DATA.Skill Skill)
        {
            if (Skill == null)
                return null;

            return new Skill()
            {
                Id = Skill.skl_id,
                IsDeleted = Skill.skl_isdeleted,
                Label = Skill.skl_label
            };
        }

        /// <summary>
        /// Function used to convert a list of Data Skills to a List of WS Skills.
        /// </summary>
        /// <param name="Skills"></param>
        /// <returns></returns>
        public static List<Skill> SkillConverter(List<DATA.Skill> Skills)
        {
            List<Skill> res = new List<Skill>();
            foreach (DATA.Skill us in Skills)
                res.Add(Tools.ObjectConverter.SkillConverter(us));

            return res;
        }

        /// <summary>
        /// Function used to convert a list of WS Skills to a List of Data Skills.
        /// </summary>
        /// <param name="Skills"></param>
        /// <returns></returns>
        public static List<DATA.Skill> SkillConverter(List<Skill> Skills)
        {
            List<DATA.Skill> res = new List<DATA.Skill>();
            foreach (Skill us in Skills)
                res.Add(Tools.ObjectConverter.SkillConverter(us));

            return res;
        }
    }
}